package com.banggood.upms.service.impl;

import com.banggood.silk.web.api.exception.SkbException;
import com.banggood.upms.bean.po.Permission;
import com.banggood.upms.dao.PermissionDao;
import com.banggood.upms.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author XuChuangFeng
 */
@Service
@Transactional(rollbackFor = SkbException.class)
public class PermissionServiceImpl extends BaseServiceImpl<Permission, PermissionDao> implements PermissionService {

    @Override
    @Autowired
    public void setDao(PermissionDao dao) {
        super.dao = dao;
    }

    @Override
    public int persistPermList(List<Permission> permissions) {
        int count = 0;
        for(Permission permission : permissions) {
            int i = dao.insert(permission);
            count += i;
        }
        return count;
    }
}
